﻿#ifndef QCONFIGFILE_H
#define QCONFIGFILE_H

#include <QObject>
#include <QJsonValue>
#include <QJsonArray>
#include <QJsonObject>

class QConfigerPrivate;

class QConfiger : public QObject
{
    Q_OBJECT
    Q_DECLARE_PRIVATE(QConfiger)

public:
    explicit QConfiger(QString baseDir="",QObject *parent = nullptr);
    ~QConfiger();

public slots:
    QString baseDir();
    void setBaseDir(QString dir);

    bool writeConfigFile(QString filePath,QJsonObject value);
    bool writeConfigFile(QString filePath,QJsonArray value);       
    QJsonValue readConfigFile(QString filePath);
    bool renameConfigFile(QString filePath,QString newFileName);
    bool removeConfigFile(QString filePath);

signals:
    void configFileAdded(QString filePath);
    void configFileRemoved(QString filePath);
    void configFileRenamed(QString oldFilePath,QString newFilePath);
    void configFileUpdated(QString filePath);

private:
    QConfigerPrivate *d_ptr;
};

#endif // QCONFIGFILE_H
